<template>
  <div>
    <page-header title="就业数据上传" content="personEmployDataUpload"></page-header>
    <page-main title="在辅导员通过数据之前均可修改">
      <el-form :model="form" ref='form'>
        <el-row>
          <el-col :span="8">
            <el-form-item label="姓名" label-width="120px">  
              <el-input v-model="form.name" :disabled="type == 'view'"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="学号" label-width="120px">   
              <el-input v-model="form.stuno" :disabled="type == 'view'"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="性别" label-width="120px">   
              <el-select
                v-model="form.sex"
                filterable
                allow-create
                default-first-option
                :disabled="type == 'view'"
                placeholder="请选择性别">
                <el-option
                label="男"
                value="男">
                </el-option>
                <el-option
                label="女"
                value="女">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="班级" label-width="120px">   
              <el-input v-model="form.clazz" :disabled="type == 'view'"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="专业" label-width="120px">
              <el-select v-model="form.profession" placeholder="请选择" :disabled="type == 'view'">
                  <el-option
                  v-for="item in professionList"
                  :key="item.id"
                  :label="item.professionname"
                  :value="item.id">
                  </el-option>
              </el-select>
            </el-form-item>  
          </el-col>
          <el-col :span="8">
            <el-form-item label="年级" label-width="120px">   
              <!-- <el-input v-model="form.graduateyear" :disabled="type == 'view'"/> -->
              <el-select
                  v-model="form.graduateyear"
                  filterable
                  allow-create
                  default-first-option
                  :disabled="type == 'view'"
                  placeholder="请选择文章年级">
                  <el-option
                  label="2017"
                  value="2017">
                  </el-option>
                  <el-option
                  label="2018"
                  value="2018">
                  </el-option>
                  <el-option
                  label="2019"
                  value="2019">
                  </el-option>
                  <el-option
                  label="2020"
                  value="2020">
                  </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="学历" label-width="120px">   
              <el-col :span="12">
                  <el-select
                    v-model="form.education"
                    filterable
                    allow-create
                    default-first-option
                    :disabled="type == 'view'"
                    placeholder="请选择学历">
                    <el-option
                    label="小学"
                    value="小学">
                    </el-option>
                    <el-option
                    label="初中"
                    value="初中">
                    </el-option>
                    <el-option
                    label="高中"
                    value="高中">
                    </el-option>
                    <el-option
                    label="本科"
                    value="本科">
                    </el-option>
                    <el-option
                    label="研究生"
                    value="研究生">
                    </el-option>
                </el-select>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="薪资" label-width="120px">   
              <el-col :span="12">
                <el-input v-model="form.salary" :disabled="type == 'view'"/>
              </el-col>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-form-item label="" label-width="120px">   
            <el-col :span="12" v-if="type == 'view'">
              <h3>*管理员已对该信息处理，不可更改，感谢您为应届生群体做出的贡献！</h3>
            </el-col>
          </el-form-item>
        </el-row>
        <el-row><br><br><br></el-row>
        <el-row>
          <el-form-item label="" label-width="120px">
            <el-button type="primary" v-if="type != 'view'" @click="update()">确定</el-button>
            <el-button @click="cannelBuild()">取消</el-button>
          </el-form-item>
        </el-row>
      </el-form>
    </page-main>
  </div>
</template>

<script>
export default {
    name: 'personEmployDataUpload',
    data() {
        return {
          form: {},
          professionList: [],
          type: ''
        }
    },
    created() {
      this.$util.post('public/loadAllProfession').then(res => {
          this.professionList = []
          for(let i = 0; i < res.length; i++) {
              this.professionList.push(res[i])
          }
      })
      let uid = this.$store.getters['user/uid'].id
      this.$util.post('public/selectRGByUid', {uid: uid}).then(res => {
        if(res != null && res.id != undefined) {
          this.form = res
          if(res.signin == 1) {
            this.type = 'view'
          }
        }
      })
    },
    methods: {
      update() {
        this.form.uid = this.$store.getters['user/uid'].id
        this.form.signin = 0
        this.form.work = 1
        this.$util.post('public/userUpdateRGByPrimaryKey', this.form).then(res => {
          this.$message({
              message: '更新成功，管理员马上处理！',
              type: 'success'
          });
        })
      },
      cannelBuild() {
        this.$router.push('/dashboard')
      }
    }
}
</script>
